package com.ymttest.utils;

import java.lang.reflect.Method;

import com.ymt.core.tool.Logger;

public class GenerateTestData {
	@SuppressWarnings({ "null", "unused" })
	public static void main(String[] args) {
		/*String env = "UAT";
		String className = "com.ymttest.business.datajob.TestFunction";
		String methodName = "addProduct";
		String parameters = "3383,wesper";
		*/
		
		
		
		String env = args[0];
		String className = args[1];
		String methodName = args[2];
		String parameters = args[3];
		initProp(env);
		
		
		try {
			Class<?> class1 = Class.forName(className);
			
			if (parameters!=null || !parameters.equals("")){
				String[] parametersAry = parameters.split(",");
				Method method = class1.getMethod(methodName,String[].class);
				method.invoke(null, new Object[]{parametersAry});
			}else{
			
				Method method = class1.getMethod(methodName);
				method.invoke(null);
			}
			
			
		
			System.out.println("=============== 执行完毕   =================");
		
		} catch (Exception e) {
			
			e.printStackTrace();
		}
	}
	
	
	
	public static void initProp(String env) {
		EnvSetup.setEnv(env.toLowerCase());
		//通过jenkins 跑case ，强制设置控制台不输出case 运行日志
		Logger.setDebug(false);	
		Logger.info("jenkins 运行日志开启状态为：" + Logger.isDebug());
		String dns = EnvSetup.getSystemUrl("dns");
		if (TestDataManager.isWindowsOS()) {
			if (dns != null && !dns.equals("null") && dns.length() > 0) {
				TestDataManager.ChangeDns("本地连接", dns);
			}
		}
	}

}
